package com.aaron.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;


@AllArgsConstructor
@Getter
public enum CompressTypeEnum {
    //这是一个枚举实例,code为0x01,name为gzip
    GZIP((byte) 0x01, "gzip");

    private final byte code;
    private final String name;

    //如果传入的code == 0x01,就返回gzip。否则返回null
    public static String getName(byte code) {
        /**
         * CompressTypeEnum.values():就是枚举实例的名字GZIP
         */
        for (CompressTypeEnum c : CompressTypeEnum.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        return null;
    }

}
